
package com.scs.application.modules.msg.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import com.scs.application.core.service.BaseServiceImpl;
import com.scs.application.core.utils.StringUtils;
import com.scs.application.modules.msg.entity.Scene;
import com.scs.application.modules.msg.mapper.SceneMapper;
import com.scs.application.modules.msg.request.SceneQueryRequest;
import com.scs.application.modules.msg.service.SceneService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 场景定义 service 实现
*
*/
@Slf4j
@Service
public class SceneServiceImpl extends BaseServiceImpl<SceneMapper, Scene> implements SceneService {

    @Override
    public List<Scene> list(SceneQueryRequest request) {
        List<Scene> list = this.list(Wrappers.<Scene>query()
                .eq(StringUtils.isNotBlank(request.getCode()), "code", request.getCode())
                .like(StringUtils.isNotBlank(request.getName()), "name", request.getName())
            .orderByDesc("gmt_modified")
        );
        return list;
    }

    @Override
    public IPage<Scene> page(SceneQueryRequest request) {
        IPage page = this.page(request.getPage(), Wrappers.<Scene>query()
                .eq(StringUtils.isNotBlank(request.getCode()), "code", request.getCode())
                .like(StringUtils.isNotBlank(request.getName()), "name", request.getName())
            .orderByDesc("gmt_modified")
        );
        return page;
    }
}
